package com.free4inno.knowledgems.utils;

import lombok.extern.slf4j.Slf4j;

/**
 * Author: HaoYi.
 * Date: 2020/9/19.
 */

@Slf4j
public class StringUtils {

    /**
     * @param str 从数据库中取出要返回前端的字符串
     * @return 将双引号替换完成的字符串, 将换行符替换成<br />
     */
    public static String inputStringFormat(String str) {
        log.info("StringUtils" + "----in----" + "将字符串格式化返回前端" + "----");
        if (str == null || str.length() == 0) {
            log.info("StringUtils" + "----out----" + "返回\"\"，字符串为空" + "----");
            return "";
        }
        log.info("StringUtils" + "----out----" + "返回格式化后的字符串，已将换行替换为<br/>标签" + "----");
        return str.replaceAll("\r\n", "<br/>")
                .replaceAll("\n\r", "<br/>")
                .replaceAll("\n", "<br/>")
                .replaceAll("\r", "<br/>");
//        .replaceAll("\"", "&quot;")
    }
}
